package com.csx.saas.merchant.tenant.enumeration;

import com.csx.basic.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 企业
 * </p>
 *
 * @author ChenSongXin
 * @date 2021-03-15
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "TenantChannelEnum", description = "渠道\n#{SYSTEM:平台开通;REGISTER:注册-枚举")
public enum TenantChannelEnum implements BaseEnum {

    /**
     * SYSTEM="平台开通"
     */
    SYSTEM("平台开通"),
    /**
     * REGISTER="注册"
     */
    REGISTER("注册"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static TenantChannelEnum match(String val, TenantChannelEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static TenantChannelEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(TenantChannelEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "SYSTEM,REGISTER", example = "SYSTEM")
    public String getCode() {
        return this.name();
    }

}
